package util;


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class ThreadDemo {

    static void testBusyThread() {
        new Thread(() -> {
            System.out.println("busy thread start");
            for(;;)
                ;
        }).start();
    }

    static void testWait() {
        new Thread(() -> {
            System.out.println("wait thread start");
            Object obj = new Object();
            synchronized (obj) {
                try {
                    obj.wait();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }).start();
    }

    public static void main(String[] args) throws IOException {
        BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
        System.out.print("wait input: ");
        input.readLine();
        testWait();
        System.out.print("wait input: ");
        input.readLine();
        testBusyThread();
    }
}
